package com.study.talk.util;

import android.app.ActivityManager;
import android.content.Context;
import android.content.res.Configuration;
import android.util.Log;

import java.util.List;

public class ActivityUtil {
    private static final String TAG = "ActivityUtil";

    public static String getTopActivityName(Context context){
       ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningTaskInfo> appTasks = manager.getRunningTasks(1);
        if (appTasks != null) {
            Log.e(TAG, "getTopActivityName: "+appTasks.get(0).topActivity.getClassName());
            return appTasks.get(0).topActivity.getClassName();
        }else return null;
    }

    public static boolean isPad(Context context) {
        return (context.getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK)
                >= Configuration.SCREENLAYOUT_SIZE_LARGE;
    }
}
